package com.sdhs.projectstart.controller;

import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.core.page.TableDataInfo;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.projectstart.domain.ProjectScheme;
import com.sdhs.projectstart.service.IProjectSchemeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目启动--施工组织方案Controller
 *
 * @author ruoyi
 * @date 2025-03-20
 */
@RestController
@RequestMapping("/projectStart/scheme")
public class ProjectSchemeController extends BaseController {
    @Autowired
    private IProjectSchemeService projectSchemeService;

    /**
     * 查询项目启动--施工组织方案列表
     */
    @PreAuthorize("@ss.hasPermi('projectStart:scheme:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectScheme projectScheme) {
        startPage();
        List<ProjectScheme> list = projectSchemeService.selectProjectSchemeList(projectScheme);
        return getDataTable(list);
    }

    /**
     * 获取项目启动--施工组织方案详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectStart:scheme:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(projectSchemeService.selectProjectSchemeById(id));
    }

    /**
     * 新增项目启动--施工组织方案
     */
    @PreAuthorize("@ss.hasPermi('projectStart:scheme:add')")
    @Log(title = "项目启动--施工组织方案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectScheme projectScheme) {
        return success(projectSchemeService.insertProjectScheme(projectScheme));
    }

    /**
     * 修改项目启动--施工组织方案
     */
    @PreAuthorize("@ss.hasPermi('projectStart:scheme:edit')")
    @Log(title = "项目启动--施工组织方案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectScheme projectScheme) {
        return toAjax(projectSchemeService.updateProjectScheme(projectScheme));
    }

    /**
     * 删除项目启动--施工组织方案
     */
    @PreAuthorize("@ss.hasPermi('projectStart:scheme:remove')")
    @Log(title = "项目启动--施工组织方案", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(projectSchemeService.deleteProjectSchemeByIds(ids));
    }
}
